using UnityEngine;

public struct HitBullet
{
	public static int numHits = -360000000;

	public static HitBullet lastHit = default(HitBullet);

	public int id;

	public ShotBullet bullet;

	public RaycastHit2D raycastHit;

	public Collider2D collider;

	public Vector2 localPoint;

	public float scaleDamage;

	public float damage;

	public float scaleMaterial;

	public int countHits;

	public float impulse;

	public Vector2 impulseDirection;

	public WeaponHands weapon;

	public WeaponCartridge cartridge;

	public WeaponSourceBullets cartridgeRay;

	public IWeaponCartridgeEntity entity;

	public int idShot;

	public HitBullet(WeaponCartridge cartridge, ShotBullet bullet, WeaponHands weapon, WeaponSourceBullets cartridgeRay, RaycastHit2D rayHit)
	{
		numHits++;
		id = numHits;
		this.bullet = bullet;
		this.weapon = weapon;
		idShot = Mathf.FloorToInt(Time.time) + weapon.magazine * 1000;
		this.cartridge = cartridge;
		this.cartridgeRay = cartridgeRay;
		raycastHit = rayHit;
		collider = rayHit.collider;
		localPoint = rayHit.collider.transform.InverseTransformPoint(rayHit.point);
		entity = WeaponCartridge.GetEntity(rayHit.collider);
		scaleDamage = PhysicsMaterialMultiply.GetScaleDamage(rayHit.collider.sharedMaterial, cartridgeRay.damageMultiply, lastHit, bullet);
		damage = cartridgeRay.damage / (float)cartridgeRay.bullets * scaleDamage;
		impulse = cartridgeRay.impulse / (float)cartridgeRay.bullets * scaleDamage;
		impulseDirection = this.bullet.rayDirection * impulse;
		scaleMaterial = PhysicsMaterialMultiply.GetScaleDamage(rayHit.collider.sharedMaterial, cartridgeRay.damageMultiply);
		countHits = 1;
		if (lastHit.bullet.id == bullet.id)
		{
			countHits = lastHit.countHits + 1;
		}
		lastHit = this;
	}

	public bool StopBullet()
	{
		return countHits == bullet.maxHits || PhysicsMaterialMultiply.StopBullet(collider.sharedMaterial, cartridgeRay.damageMultiply);
	}
}
